package com.lzwork.gpt.utility.batchjob;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.lzwork.utility.data.list.StringListWrapper;
import com.lzwork.utility.pair.StringPair;
import com.lzwork.utility.str.StrUtility;

/**
 * @author LiZheng
 * @date 2024年8月1日 11:52:11
 */

public class JobOptionImport extends JobOption
{
	final static String DEF_CONTENT = "内容描述";
	final static String DEF_IDKEY = "工单编号";

	@Override
	protected String defIdKey()
	{
		return DEF_IDKEY;
	}

	@Override
	protected String defContent()
	{
		return DEF_CONTENT;
	}

	protected StringListWrapper fields = new StringListWrapper("fields", true, true, true);

	@Override
	protected void refreshParamInfo()
	{
		super.refreshParamInfo();

		paramInfoMap.put(fields.key(), new StringPair("其他保留输出", "每行一个。留空的话保留全部字段。"));
	}

	@Override
	protected void afterSetData()
	{
		Iterator<String> fIt = fields.value().iterator();
		while (fIt.hasNext())
		{
			String str = fIt.next();
			if (!StrUtility.stringValid(str))
				fIt.remove();
		}
	}

	public boolean fullKey()
	{
		return fields.value().isEmpty();
	}

	public List<String> getFields()
	{
		return fields.value();
	}

	public List<String> sourceHead()
	{
		List<String> head = new ArrayList<>();
		head.add(idKey.value());
		head.addAll(fields.value());
		head.add(contentKey.value());
		return head;
	}

	@Override
	public List<String> fieldFilter()
	{
		return fields.value();
	}
}
